<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<h1>用户登入</h1>
<span>用户名:</span><input type="text" name="username"></br>
<span>密码:</span><input type="password" name="password"></br>
<input type="button" value="登入" onclick="login()"></br>
<script>
         function login(){
            $.ajax({
             type:"post",
             url:"/User/login",
             data:{
                username: $("input[name='username']").val(),
                password: $("input[name='password']").val()
             },
             success:function(data){
                 if(data){
                    location.href="index.html";
                 }else{
                     alert("用户名或密码错误");
                 }
             },
            });
            }

     </script>
</body>
</html>